#include "stable.h"
#include "QkTocView.h"

QkTocView::QkTocView()
{
	init();
}

QkTocView::QkTocView(QWidget *parent) : QkBaseView(parent)
{
	init();
}

QkTocView::~QkTocView()
{
}

QKindleViewId QkTocView::viewId() const
{
	return QKindleTocView;
}

void QkTocView::on_listView_clicked(const QModelIndex &index)
{
	Q_UNUSED(index);

	emit navigate(this, "comic");
}

void QkTocView::activated()
{
	toolBar()->setActions(m_actions);
}

void QkTocView::deactivated()
{
}

void QkTocView::init()
{
	QAction *openAction = new QAction("Open", this);
	openAction->setObjectName("openAction");
	m_actions.append(openAction);
	QAction *exitAction = new QAction("Exit", this);
	exitAction->setObjectName("exitAction");
	m_actions.append(exitAction);

	QVBoxLayout *v = new QVBoxLayout(this);
	m_listView = new QListView();
	m_listView->setObjectName("listView");

	m_model = new QkTocModel();
	m_listView->setModel(m_model);

	v->addWidget(m_listView);

	v->setMargin(0);
	setLayout(v);

	QMetaObject::connectSlotsByName(this);
}

void QkTocView::on_openAction_triggered()
{
	emit navigate(this, "comic");
}

void QkTocView::on_exitAction_triggered()
{
}